package com.earth.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

@Configuration
@EnableSwagger2
//@Profile({"dev"})
public class Swagger2Config {

	@Bean
	public Docket createRestApi() {
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("项目名称") //网站标题
                .description("项目名称swagger RESTful APIs......") //网站描述
                .version("9.0") //版本
                .contact(new Contact("郑鑫程","http://localhost:8080","zhengxincheng@yahoo.com")) //联系人
                .license("The Apache License") //协议
                .licenseUrl("http://www.baidu.com") //协议url
                .build();

        return new Docket(DocumentationType.SWAGGER_2) //swagger版本
                .pathMapping("/")
                .select()
                //扫描那些controller
                .apis(RequestHandlerSelectors.basePackage("com.earth"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo);
    }
}
